package com.drcoffee.drcoffeemall.mapper;

import com.drcoffee.drcoffeemall.entry.Trade;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface TradeMapper {
    @Insert("INSERT INTO t_trade VALUES (#{id},#{order_code},#{trade_date},#{trade_no},#{refund_id},#{trade_amount},#{trade_type},#{trade_platform})")
    void saveTrade(Trade trade);

    @Select("SELECT * FROM t_trade WHERE order_code = #{order_code} AND trade_type = #{trade_type}")
    Trade getTradeByOrder(String orderCode, String trade_type);

    @Select("SELECT COUNT(*) FROM t_trade WHERE order_code = #{out_trade_no} and trade_type = #{trade_type}")
    Integer getTradeNum(String out_trade_no, String trade_type);

}
